home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
WINDOWS
/
MDIT.ARJ
/
PCTHREAD.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-30
|
10KB
|
414 lines
/****************************************************************
* (C) The TriTechnology Company, 1991 *
* Bellevue, Wa. 98005 *
* *
* This software is furnished under a license and may *
* be used and copied only in accordance with the terms *
* of such license and with the inclusion of the above *
* copyright notice. this software or any other copies *
* thereof may not be provided or otherwise made avail- *
* able to any other person. No title to and ownership *
* of the software is hereby transferred. *
* *
* The information in this software is subject to change *
* without notice and should not be construed as a *
* commitment by The TriTechnology Company. *
****************************************************************
*
* Facility:
*
* pcthread.h
*
* Abstract:
*
* PCthreads(tm) Application Programming Interface, API.
* The functions declared in this header file may be called
* by application programs (aka client applications) whose
* design requires multiple threads of execution. These
* functions provide a complete set of primitives necessary
* for the creation, run-time management, and deletion of
* threads, mutexes, and condition variables. Moreover,
* these routines are all that are required to design higher
* level abstractions, such as monitors, counting sema-
* phores, friendly mutexes, etc,.
*
*/
#ifndef _PCTHREAD_H
#define _PCTHREAD_H
#include "typedefs.h"
#include "except.h"
/*
* -- Clients may initialize the Run-Time Management System, RTMS using
* their own settings. This is not a required service. For it to
* have any effect it must be the very first service called.
*/
int
pcthread_attr_setdefaults_np( policy_t scheduling_policy,
unsigned thread_quantum,
int max_thread_priority,
int default_thread_priority,
unsigned default_thread_stack_size,
boolean_t thread_inheritance );
/*
* -- Thread attributes object services.
*/
int
pcthread_attr_create( pcthread_attr_t *th_attr );
int
pcthread_attr_delete( pcthread_attr_t *th_attr );
int
pcthread_attr_setprio( pcthread_attr_t *th_attr, int prio );
int
pcthread_attr_getprio( pcthread_attr_t th_attr );
int
pcthread_attr_setsched( pcthread_attr_t *th_attr, int policy );
int
pcthread_attr_getsched( pcthread_attr_t th_attr );
int
pcthread_attr_setinheritsched( pcthread_attr_t *attr, int inherit );
int
pcthread_attr_getinheritsched( pcthread_attr_t th_attr );
int
pcthread_attr_setstacksize( pcthread_attr_t *attr, int stacksize );
int
pcthread_attr_getstacksize( pcthread_attr_t th_attr );
int
pcthread_attr_getmaxprio_np( void );
int
pcthread_attr_setquantum_np( pcthread_attr_t *attr, int quantum );
int
pcthread_attr_getquantum_np( pcthread_attr_t th_attr );
pcthread_attr_t *
pcthread_attr_default_np( void );
/*
* -- Allow client threads to operate on mutex attributes objects.
*/
int
pcthread_mutexattr_create( pcthread_mutexattr_t *mu_attr );
int
pcthread_mutexattr_delete( pcthread_mutexattr_t *mu_attr );
int
pcthread_mutexattr_setprotocol(pcthread_mutexattr_t *attr, sched_protocol_t p);
int
pcthread_mutexattr_getprotocol( pcthread_mutexattr_t mu_attr );
pcthread_mutexattr_t *
pcthread_mutexattr_default_np( void );
/*
* -- Allow threads to operate on condition variable attributes objects.
*/
int
pcthread_condattr_create( pcthread_condattr_t *cv_attr );
int
pcthread_condattr_delete( pcthread_condattr_t *cv_attr );
pcthread_condattr_t *
pcthread_condattr_default_np( void );
/*
* -- Thread-specific services. First, thread creation
*/
int
pcthread_create( pcthread_t *th_handle,
pcthread_attr_t th_attr,
pcthread_action_t action,
pcthread_addr_t *argument );
/*
* -- A thread may wait for the completion of another and obtain the return
* value of its action routine, if any.
*/
int
pcthread_join( pcthread_t th_handle, pcthread_addr_t *status );
/*
* -- A thread may terminate itself and pass a status value back to any
* thread that is waiting for it to complete (i.e., via the
* pcthread_join() service ).
*/
void
pcthread_exit( pcthread_addr_t status );
/*
* -- A thread may use pcthread_detach() to indicate to the run time system
* that its resources (e.g., memory) may be reclaimed upon termination.
* This does not cause the thread to terminate, but does preclude any
* threads from joining with it, once pcthread_detach() has been called.
*/
int
pcthread_detach( pcthread_t *th_handle );
/*
* -- Client applications may adjust a thread's priority
*/
int
pcthread_setprio( pcthread_t *th_handle, int priority );
int
pcthread_getprio( pcthread_t *th_handle );
int
pcthread_setactive_prio_np( int p );
int
pcthread_getactive_prio_np( void );
int
pcthread_setscheduler( pcthread_t *th_handle, int policy, int priority );
int
pcthread_getscheduler( pcthread_t th_handle );
int
pcthread_setattr( pcthread_t th_handle, pcthread_attr_t attr );
int
pcthread_getattr( pcthread_t th_handle, pcthread_attr_t *attr );
/*
* -- Client threads may obtain their own handles
*/
pcthread_t *
pcthread_self( void );
/*
* -- Client threads may unconditionally yield the processor.
*/
void
pcthread_yield( void );
/*
* -- Client threads may execute a timed delay until a specified time, or
* for a specified interval of time.
*/
void
pcthread_delay_absolute_np( timespec_t *abstime );
void
pcthread_delay_relative_np( timespec_t *time_delay );
/*
* -- Client applications may test two threads for equality
*/
int
pcthread_equal( pcthread_t th1_handle, pcthread_t th2_handle );
/*
* -- Mutex services
*/
int
pcthread_mutex_init( pcthread_mutex_t *mutex, pcthread_mutexattr_t mu_attr );
int
pcthread_mutex_destroy( pcthread_mutex_t *mu_handle );
int
pcthread_mutex_blockedthreads_np( pcthread_mutex_t *mu_handle );
int
pcthread_mutex_lock( pcthread_mutex_t *mu_handle );
int
pcthread_mutex_unlock( pcthread_mutex_t *mu_handle );
int
pcthread_mutex_trylock( pcthread_mutex_t *mu_handle );
/*
* -- Condition variable services
*/
int
pcthread_cond_init( pcthread_cond_t *cv, pcthread_condattr_t cv_attr );
int
pcthread_cond_destroy( pcthread_cond_t *cv_handle );
int
pcthread_cond_waitingthreads_np( pcthread_cond_t *cv_handle );
int
pcthread_cond_wait( pcthread_cond_t *cv, pcthread_mutex_t *mutex );
int
pcthread_cond_timedwait( pcthread_t *cv, pcthread_mutex_t *mu, timespec_t *t );
int
pcthread_cond_signal( pcthread_cond_t *cv_handle );
int
pcthread_cond_broadcast( pcthread_cond_t *cv_handle );
/*
* -- Disable and Enable asynchronous (aka clock-mediated) preemption
*/
int
pcthread_disable_preemption_np( void );
void
pcthread_enable_preemption_np( int );
/*
* -- Enable and disable thread execution tracing. Allow the user to
* specify an output file.
*/
void
pcthread_enable_trace_np( char *filename );
void
pcthread_disable_trace_np( void );
/*
* -- Thread cancellation services
*/
int
pcthread_cancel( pcthread_t th_handle );
void
pcthread_testcancel( void );
int
pthread_setcancel( int cancelability );
/*
* -- Allow the user to use her own thread-specific cleanup routines
*/
void
pcthread_handler_install_np( pcthread_handler_t handler,
pcthread_addr_t argument );
void
pcthread_handler_remove_np( pcthread_handler_t handler );
/*
* -- Return the amount of elapsed time since the application began.
*/
void
pcthread_clock_np( timespec_t *time );
/*
* -- Calculate the expiration time, when given an amount of time to wait.
*/
void
pcthread_get_expiration_np( timespec_t *delta, timespec_t *absolute );
/*
* -- Check the value of the thread specific errno
*/
int
pcthread_errno_np( void );
/*
* -- Allow client threads to raise an exception.
*/
void
pcthread_exception_raise_np( exception_block_t far *ex, int n );
/*
* -- Shut down the system gracefully. Client threads should use this
* when they CATCH a raised exception (see previous service).
*/
void
pcthread_shutdown_np( char *module_name,
char *function_name,
char *exception_message,
exception_t exception_code );
/*
* -- Returns the number of stack words (word = 2 bytes) remaining.
*/
int
pcthread_checkstack_np( char *function_name );
/*
* -- Thread-safe malloc() and free() routines
*/
void *
pcthread_malloc_np( unsigned block_size );
void
pcthread_deallocate_np( void *ptr );
HANDLE
pcthread_window_getinstance_np( void );
pcthread_state_t
pcthread_checkstate_np( pcthread_t *th_handle );
/*
* -- These typedefs are required by the P1003.4a standard and
* relieve the user from the tedium of allocating attributes
* handles at runtime when the client code will be using the
* system's default attributes.
*/
#define pcthread_attr_default (*(pcthread_attr_default_np()))
#define pcthread_mutexattr_default (*(pcthread_mutexattr_default_np()))
#define pcthread_condattr_default (*(pcthread_condattr_default_np()))
#endif